﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using socialnexus.classes.models;

namespace socialnexus.classes.pages
{
    public class ProtectedPage : System.Web.UI.Page
    {
        protected void Page_Init(object sender, EventArgs e)
        {
            RequireAdminUser();
        }

        public void RequireAdminUser()
        {
            if (!IsAuthenticated())
            {
                //Response.Redirect("~/admin");
                //Response.Close();
            }
        }

        public bool IsAuthenticated()
        {
            return Session["admin"] != null;
        }

        protected SiteUser getSiteUser()
        {
            return SiteUser.GetById(Request.QueryString["UserId"]);
        }
    }
}
